unit Interface_Console;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TWndConsole = class(TForm)
    ScrollBar: TScrollBar;
    procedure FormPaint(Sender: TObject);
  private
    OutPutBuffer : Array of String;
  public
    procedure PrintLn(const s : String);
  end;

var
  WndConsole: TWndConsole;

procedure ConsolePrint(Msg : PChar); stdcall;

implementation

{$R *.dfm}

procedure ConsolePrint(Msg : PChar); stdcall;
begin
  WndConsole.PrintLn(Msg);
end;

procedure TWndConsole.FormPaint(Sender: TObject);
var
  i, tH : Integer;
begin
  with Canvas do
  begin
    tH := TextHeight('8');
    for i := 0 to High(OutPutBuffer) do
    begin
      TextOut(0, i*tH, '> ' + OutPutBuffer[i]);
    end;
  end;
end;

procedure TWndConsole.PrintLn(const s: String);
begin
  SetLength(OutPutBuffer, Length(OutPutBuffer)+1);
  OutPutBuffer[High(OutPutBuffer)] := s;
  Repaint;
end;

end.
